package com.example.threaddemo;

/**
 * 枚举可以看成一个小型的mysql
 * CountryEnum  ---- dbName
 * ONE          ---- table
 * 1            ---- id
 * name         ---- 字段名
 */
public enum CountryEnum {
    ONE(1,"齐国","齐王"),
    TWO(2,"楚国","楚王"),
    THREE(3,"燕国","燕王"),
    FOUR(4,"赵国","赵王"),
    FIVE(5,"魏国","魏王"),
    SIX(6,"韩国","韩王");

    @lombok.Getter
    private Integer id;

    @lombok.Getter
    private String name;

    @lombok.Getter
    private String king;


    CountryEnum(Integer id, String name, String king) {
        this.id = id;
        this.name = name;
        this.king = king;
    }

    public static CountryEnum forEach_Enum(int index){
        //枚举自带的对自己的遍历
        CountryEnum[] myArray = CountryEnum.values();
        for (CountryEnum element : myArray) {
            if (index == element.getId()) {
                return element;
            }
        }
        return null;
    }
}
